package com.yy.job.common.enums;

import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;

/**
 * job状态
 * 
 * @author eleven.li
 *
 */
public enum JobStatusEnum {

	CREATE("C", "创建"), LOCK("L", "锁定"), SUCCESS("S", "成功"), FAIL("F", "失败"), CLOSE("G", "关闭"),;

	private String code;
	private String name;

	JobStatusEnum(String code, String name) {
		this.code = code;
		this.name = name;
	}

	public String getCode() {
		return this.code;
	}

	public String getName() {
		return this.name;
	}

	public static JobStatusEnum findByCode(String code) {
		if (StringUtils.isEmpty(code)) {
			return null;
		}
		return Stream.of(JobStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
	}
}
